<html>
<head><meta charset="utf-8"><title>Why are feature gates checked during parsing? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F.html">Why are feature gates checked during parsing?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232655211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20are%20feature%20gates%20checked%20during%20parsing%3F/near/232655211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F.html#232655211">(Mar 31 2021 at 19:57)</a>:</h4>
<p>E0554, "<code>#![feature]</code> may not be used on the stable channel", is reported during parsing, before a tcx is created: <a href="https://github.com/rust-lang/rust/blob/a5029ac0ab372aec515db2e718da6d7787f3d122/compiler/rustc_ast_passes/src/feature_gate.rs#L742-L755">https://github.com/rust-lang/rust/blob/a5029ac0ab372aec515db2e718da6d7787f3d122/compiler/rustc_ast_passes/src/feature_gate.rs#L742-L755</a>. Why is that? Couldn't features be gated after parsing instead?</p>



<a name="232655469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20are%20feature%20gates%20checked%20during%20parsing%3F/near/232655469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F.html#232655469">(Mar 31 2021 at 19:59)</a>:</h4>
<p>No, because we don't want to accept unstable syntax during the parsing stage, as procedural macros would then receive potentially unstable syntax and changes to the parsing, including removal of the unstable feature, would be then a breaking change even though the user did not use feature(...)</p>



<a name="232655518"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20are%20feature%20gates%20checked%20during%20parsing%3F/near/232655518" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F.html#232655518">(Mar 31 2021 at 19:59)</a>:</h4>
<p>ahhh that makes sense</p>



<a name="232655524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Why%20are%20feature%20gates%20checked%20during%20parsing%3F/near/232655524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Why.20are.20feature.20gates.20checked.20during.20parsing.3F.html#232655524">(Mar 31 2021 at 19:59)</a>:</h4>
<p>thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>